﻿@model Retete.ViewModels.InventarViewModel
@{
    ViewBag.Title = "Inventar";
}

<script type="text/javascript">
    window.onload = function () {
        if (FocusProdusNou.value == "True") ProdusNouCod.focus();
    }

    function stergeInregistrare(id) {
        if (confirm("Doriti sa stergeti produsul selectat?") == true) {
            IDProdusSters.value = id;
            form.submit();
        }
    }
    function submitOnEnter() {
        if (event.keyCode == "13") form.submit();
    }
</script>

@using (Html.BeginForm(null, null, FormMethod.Post, new { id = "form", name = "form" }))
{
    <table style="width: 100%">
        <tr>
            <td style="width: 190px; vertical-align: top; border-right-style: dashed; border-right-color: #CFCFCF; border-right-width: 1px;">
                <fieldset>
                    <legend>Activitati</legend>

                    <p class="toolbox"><a href="javascript:form.submit()">Accepta</a></p>
                    <p class="toolbox">@Html.ActionLink("Renunta", "Index")</p>
                </fieldset>
            </td>

            <td style="vertical-align: top;">
                @Html.ValidationSummary()
                @Html.HiddenFor(element => element.FocusProdusNou)
                @Html.HiddenFor(element => element.IDProdusSters)

                <fieldset>
                    <legend>Introducere stoc real</legend>

                    <table class="grid">
                        <thead>
                            <tr>
                                <td style="width: 70px">Cod</td>
                                <th>Produs</th>
                                <th style="width: 100px">Categorie</th>
                                <th style="width: 65px">Unitate</th>
                                <th style="width: 100px">Pret cumparare</th>
                                <th style="width: 100px">Pret vanzare</th>
                                <th style="width: 139px">Cantitate</th>
                            </tr>
                        </thead>

                        <tbody>
                            <tr class="insertionRow">
                                <td>@Html.TextBoxFor(model => model.ProdusNouCod, new { autocomplete = "off", placeholder = Model.CodUltimulProdus })</td>
                                <td>@Html.TextBoxFor(model => model.ProdusNouNume, new { autocomplete = "off", placeholder = "Produs nou" })</td>
                                <td>@Html.TextBoxFor(model => model.ProdusNouCategorie, new { autocomplete = "off" })</td>
                                <td>@Html.TextBoxFor(model => model.ProdusNouUnitate, new { autocomplete = "off" })</td>
                                <td>@Html.TextBoxFor(model => model.ProdusNouPret, new { autocomplete = "off" })</td>
                                <td>@Html.TextBoxFor(model => model.ProdusNouPretVanzare, new { autocomplete = "off" })</td>
                                <td>@Html.TextBoxFor(model => model.ProdusNouCantitate, new { autocomplete = "off", onkeydown = "return submitOnEnter()" })</td>
                            </tr>

                            @if (Model.Stoc != null)
                            {
                                for (int i = 0; i < Model.Stoc.Count; i++)
                                {
                                    <tr>
                                        <td>
                                            @Html.DisplayTextFor(element => element.Stoc[i].Cod)
                                            @Html.HiddenFor(element => element.Stoc[i].Cod)
                                        </td>
                                        <td>
                                            @Html.DisplayTextFor(element => element.Stoc[i].Nume)
                                            @Html.HiddenFor(element => element.Stoc[i].Nume)
                                            @Html.HiddenFor(element => element.Stoc[i].ID)
                                        </td>
                                        <td>
                                            @Html.DisplayTextFor(element => element.Stoc[i].Categorie)
                                            @Html.HiddenFor(element => element.Stoc[i].Categorie)
                                        </td>
                                        <td>
                                            @Html.DisplayTextFor(element => element.Stoc[i].UnitateMasura)
                                            @Html.HiddenFor(element => element.Stoc[i].UnitateMasura)
                                        </td>
                                        <td class="insertionCell">@Html.TextBoxFor(element => element.Stoc[i].PretCumparare)</td>
                                        <td class="insertionCell">@Html.TextBoxFor(element => element.Stoc[i].Pret)</td>
                                        <td class="insertionCell">
                                            @Html.TextBoxFor(element => element.Stoc[i].Cantitate)
                                            @Html.HiddenFor(element => element.Stoc[i].CantitateTeoretica)
                                        </td>
                                    </tr>
                                }
                            }
                        </tbody>
                    </table>
                </fieldset>
            </td>
        </tr>
    </table>
}